﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;

using LINQSamples.Data;

namespace Web.Samples
{
    public partial class FilteredSelect : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            this.BindQuery();
            this.BindImperative();
        }

        private void BindQuery()
        {
            var query = (from o in Product.GetProducts()
                         where o.Name.StartsWith("A")
                         select o.Name).Take(15);

            foreach (string s in query)
                this.litQueryResults.Text += s + "<br />\n";
        }

        private void BindImperative()
        {
            var query = Product.GetProducts().Where(p => p.Name.StartsWith("A")).Select(p => p.Name);

            foreach (string s in query)
                this.litImperativeResults.Text += s + "<br />\n";
        }
    }
}
